package com.shenmazong.demodelayqueuetask.controller;

import com.shenmazong.demodelayqueuetask.service.ProductService;
import com.shenmazong.demodelayqueuetask.utils.MqConstant;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.text.SimpleDateFormat;
import java.util.Date;
import java.util.HashMap;

/**
 * @program: server-java-demo
 * @description: DelayQueueController
 * @author: 亮子说编程
 * @create: 2020-11-02 16:14
 **/

@Slf4j
@RestController
@RequestMapping("/delayQueue")
public class DelayQueueController {

    @Autowired
    private ProductService productService;

    @GetMapping("/send/{time}")
    public String send(@PathVariable("time") int time){
        String now = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss").format(new Date());
        log.info("{}秒后, 发送延迟消息，当前时间{}", time, now);
        productService.send("hello,world", time, MqConstant.MY_QUEUE_TWO);

        new HashMap()

        return "ok:"+now;
    }
}
